var wcid = GetQueryString("wcid");
var dispatched = GetQueryString("dispatched");
var d_id = GetQueryString("d_id");
//显示版本号
var version = [100, 110];
//显示基本信息
var infomation = [];
for (let i = 0; i < 3; i++) {
    infomation[i] = document.getElementById("infomation" + i).children[0];
}
var sentMessage = {
    "requestType": "initBaseData",
    "wc_id": wcid
};
var postData;
$.ajax({
    url: '/op/checkTorDT',
    type: 'post',
    data: sentMessage,
    async: false,
    success: function (data, status) {
        if (status == 'success') {
            postData = data;
        }
    },
    error: function (data, status) {
        if (status == 'error') {
            alert("你的网络有问题！");
        }
    }
});
var infomationData = [
    [["项目名称", "产品名称","检测标准", "检测时间", "检测时机", "检测地点"]],
    [["增感屏", "胶片牌号", "显影时间", "显影温度", "射线源种类", "焦点尺寸", "胶片规格", "像质计型号", "洗片条件", "显影液"]],
    [["工件规格", "焦距", "分段数", "一次透照长度", "检测比例", "像质计灵敏度", "管电压/源活度", "曝光时间", "技术等级", "合格级别", "透照方式"]]
];
console.log(postData);
var date = new Date(postData[0].task_time);
postData[0].task_time=date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
date.getDate();
infomationData[0][1] = [
    postData[0].task_pname,
    postData[0].task_product,
    postData[0].task_standard,
    postData[0].task_time == null ? "" : postData[0].task_time,
    postData[0].task_opportunity,
    postData[0].task_addr
];
infomationData[1][1] = [
    postData[0].tech_screen,
    postData[0].tech_filmBrand,
    postData[0].tech_devTime,
    postData[0].tech_devT,
    postData[0].tech_ray,
    postData[0].tech_focus,
    postData[0].tech_filmV,
    postData[0].tech_IQIV,
    postData[0].tech_devCondition,
    postData[0].tech_liquor
];
infomationData[2][1] = [
    postData[0].wc_spec,
    postData[0].tech_focalDis,
    postData[0].tech_seg,
    postData[0].tech_tranLen,
    postData[0].wc_scale,
    postData[0].tech_IQISen,
    postData[0].tech_V,
    postData[0].tech_time,
    postData[0].task_level,
    postData[0].wc_qua,
    postData[0].tech_tranType
];
version = [postData[0].tech_id, postData[0].tech_version];
document.getElementById("version0").innerHTML = "工艺卡号/版本号: " + version[0];
document.getElementById("version1").innerHTML = "工艺规程号/版本: " + version[1];
for (let j = 0; j < 3; j++) {
    for (let i = 0; i < infomationData[j][0].length; i++) {
        let tr = document.createElement("tr");
        if (i % 3 === 0) {
            infomation[j].appendChild(tr);
        }
        let td = document.createElement("td");
        td.setAttribute("class", "td-shadows");
        td.setAttribute("align", "center");
        td.innerHTML = infomationData[j][0][i];
        infomation[j].children[infomation[j].childElementCount - 1].appendChild(td);
        td = document.createElement("td");
        td.setAttribute("align", "center");
        td.innerHTML = infomationData[j][1][i];
        infomation[j].children[infomation[j].childElementCount - 1].appendChild(td);
    }
}

//显示工件信息
var workpieceTable = document.getElementById("workpieceTable");
var workpieceTitle = ["部件/管线编号", "工件/焊缝编号", "部件/管线名称", "检测比例", "规格", "材质", "坡口形式", "焊接方法", "焊接时间", "检测方法", "合格级别"];
var workpieceInfomation = [];
var workInner = "";
if (dispatched == "false") {
    sentMessage = {
        "requestType": "taskpaper",
        "wc_id": wcid
    };
}
else {
    sentMessage = {
        "requestType": "dispatch",
        "d_id": d_id
    };
}
console.log(sentMessage)
$.ajax({
    url: '/op/checkTorDT',
    type: 'post',
    data: sentMessage,
    async: false,
    success: function (data, status) {
        if (status == 'success') {
            postData = data;
        }
    },
    error: function (data, status) {
        if (status == 'error') {
            alert("你的网络有问题！");
        }
    }
});
for (let i = 0; i < postData.length; i++) {
    workpieceInfomation.push([
        postData[i].w_pipeNum,
        postData[i].w_weldNum,
        postData[i].w_pipeName,
        postData[i].w_scale,
        postData[i].w_spec,
        postData[i].w_texture,
        postData[i].w_type,
        postData[i].w_weldM,
        postData[i].w_weldPer,
        postData[i].w_weldTime,
        postData[i].w_test,
        postData[i].w_qua
    ]);
}
console.log(postData);
for (let i = 0; i < workpieceTitle.length; i++) {
    workInner += "<th>" + workpieceTitle[i] + "</th>";
}
document.getElementById("workpieceTable").children[0].children[0].innerHTML = workInner;
for (let i = 0; i < workpieceInfomation.length; i++) {
    let tr = document.createElement("tr");
    let inner = "";
    for (let j = 0; j < workpieceTitle.length; j++) {
        inner += "<td>" + workpieceInfomation[i][j] + "</td>";
    }
    tr.innerHTML = inner;
    workpieceTable.children[1].appendChild(tr);
}